package cn.tedu.spring.di;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

/**
注入对象类型的数据
 */
@Component
public class UserService {
    private UserDao userDao;

    @Autowired
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }
    /*
            1.自动装配注解,注入 对象类型 和 接口类型的数据;
            2.添加位置:
                2.1 属性上
                2.2 set方法上
                2.3 构造方法上
         */
//    @Autowired

    public UserDao getUserDao() {
        return userDao;
    }
//    @Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "userDao=" + userDao +
                '}';
    }

}
